<?php
namespace Sns\Api;

use PhalApi\Api;
use Sns\Domain\User as DomainUser;

/**
 * 用户模块接口服务
 */
class User extends Api {
    public function getRules() {
        return array(
            'login' => array(
                'username' => array('name' => 'username', 'require' => true, 'min' => 1, 'max' => 50, 'desc' => '用户名','message'=>'账号或者密码有误'),
				//'email' => array('name' => 'email', 'regex' => "/^([0-9A-Za-z\\-_\\.]+)@([0-9a-z]+\\.[a-z]{2,3}(\\.[a-z]{2})?)$/i"),
                'password' => array('name' => 'password', 'require' => true, 'min' => 6, 'max' => 20, 'desc' => '密码','message'=>'账号或者密码有误'),
            ),
        );
    }
    /**
     * 账号登录接口
     * @desc 根据账号和密码进行登录操作
     * @return boolean is_login 是否登录成功
     * @return int user_id 用户ID
     */
    public function login() {
        $username = $this->username;   // 账号参数
        $password = $this->password;   // 密码参数
        // 更多其他操作……
		//$num = \PhalApi\DI()->notorm->user->count();
		
		$domain = new DomainUser();
		$userInfo = $domain->getUserInfo();
        
	
		
		
        return array('is_login' => true, 'user_id' => 8);
    }
    
    /**
     * 账号注销接口
     * @desc 用户注销退出
     * @return boolean is_loginout 退出是否成功
     */
    public function loginout() {
        // 更多其他操作……
        
        return array('is_loginout' => true);
    }
    
} 
